package com.zhihaoliang.animationtrain.main

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.zhihaoliang.animationtrain.databinding.MainItemBinding

/**
 * 创建日期：2020/3/26
 * 描述:这是Activity的基类
 * 作者:支豪亮
 */
class MainAdapter(
    val mList: MutableList<InfoBean>,
    val mIInfoCallback: IInfoCallback
) : RecyclerView.Adapter<MainAdapter.MainViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MainViewHolder {
        val binding = MainItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return MainViewHolder(binding)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: MainViewHolder, position: Int) {
        holder.binding.infoBean = mList[position]
        holder.binding.infoCallback = mIInfoCallback
    }


    class MainViewHolder(val binding: MainItemBinding) : RecyclerView.ViewHolder(binding.root)


}